<template>
  <page-main class="page-login">
    <div slot="left">
        <van-icon name="wap-home-o" @click="gotoHome"/>
    </div>
    <div class="head">
        <h5>欢迎使用</h5>
        <h3>广医云</h3>          
        <h3>在线就医服务</h3>          
    </div>
    <div class="logo">
        <van-image :src="pic.logo" width="108px" />
    </div>
    <div class="login-btn m-t-30">
        <van-button type="info" block round @click="wechatLogin" icon="wechat">微信一键登录</van-button>
        <!-- <p @click="accountLogin">账号密码登录</p> -->
    </div>
    <van-submit-bar>
        <div class="agreement">
            <van-checkbox icon-size="16" checked-color="#1989fa" v-model="checked">已阅读并同意<span @click.stop="$refs.showAgreement.init('user')">《用户协议》</span></van-checkbox>
        </div>
    </van-submit-bar>
    <show-agreement ref="showAgreement" />
</page-main>
</template>

<script>
import showAgreement from '@/components/ShowAgreement';
export default {
    data(){
        return{
            pic:{
                logo: require('@/assets/img/logo.jpg')
            },
            checked: true,
            code: null,
        }
    },
    components:{
        showAgreement,
    },
    created(){
        this.code = this.$util.getWxCode();
    },
    methods:{
        handleLogin(type){
            this.$refs[type].init();
        },
        wechatLogin(){  
            this.$store.dispatch('wechatLogin', this.code); 
        },
        accountLogin(){
            this.$util.gotoPage('/login/account', {code: this.code});
        },    
        gotoHome(){
            window.location.href = 'https://' + window.location.host;
        }
    }
}
</script>

<style>

</style>